﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MainSystemForm.handler;

namespace MainSystemForm
{
    public partial class LoginForm : Form
    {
        SQLHelper helper = new SQLHelper();
        public LoginForm()
        {
            InitializeComponent();
        }

        private void DataManageForm_Load(object sender, EventArgs e)
        {
            this.SetBounds((Screen.GetBounds(this).Width / 2) - (this.Width / 2), (Screen.GetBounds(this).Height / 2) - (this.Height / 2), this.Width, this.Height, BoundsSpecified.Location);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = string.Format("select * from users where FsLoginName = '{0}' and FsPassword = '{1}'", loginName.Text, password.Text);
            DataTable dt = helper.Selectinfo(sql);
            if (dt.Rows.Count > 0)
            {
                this.Close();
                Form form = new DataManageForm();
                form.Show();
            }
            else
            {
                MessageBox.Show("请确认用户名和密码是否正确！");
                loginName.SelectAll();
                loginName.Focus();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
